//
//  SwiftUIButtons.swift
//  SwiftUICode
//
//  Created by yangkl on 2024/2/19.
//

import SwiftUI

struct SwiftUIButtons: View {
    var body: some View {
        VStack(spacing: 20){
            ButtonOne()
            ButtonTwo()
            ButtonThree()
            ButtonFour()
            ButtonFive()
            ButtonFive()
        }
    }
}

struct ButtonOne: View {
    var body: some View {
        Button{
            //点击事件执行的代码
            print("点击了按钮")
        } label: {
            Text("Hello World")
                .fontWeight(.bold)
                .font(.title)
                .padding()
                .background(Color.purple)
                .cornerRadius(40)
                .foregroundColor(.white)
                .padding(10)
            //                .border(Color.purple, width: 5 )
                .overlay{
                    RoundedRectangle(cornerRadius: 40)
                        .stroke(.purple, lineWidth: 5)
                }
        }
    }
}

struct ButtonTwo: View {
    var body: some View {
        Button{
            print("点击了按钮")
        }label: {
            HStack{
                Image(systemName: "trash")
                    .font(.title)
                Text("删除")
                    .fontWeight(.semibold)
                    .font(.title)
            }
            .padding()
            .background(Color.red)
            //                .clipShape(Circle())
            .font(.largeTitle)
            .foregroundColor(.white)
            .cornerRadius(40)
        }
    }
}

struct ButtonThree: View {
    var body: some View {
        Button{
            print("点击了按钮")
        }label: {
            Label(
                title: { Text("编辑")
                        .fontWeight(.semibold)
                        .font(.title) },
                icon: { Image(systemName: "square.and.pencil")
                    .font(.title) }
            )
            .padding()
            .background(Color.red)
            .font(.largeTitle)
            .foregroundColor(.white)
            .cornerRadius(40)
        }
    }
}

struct ButtonFour: View {
    var body: some View {
        Button{
            print("点击了按钮")
        }label: {
            Label(
                title: { Text("编           辑")
                        .fontWeight(.semibold)
                        .font(.title) },
                icon: { Image(systemName: "square.and.pencil")
                    .font(.title) }
            )
            .frame(minWidth: 0, maxWidth: .infinity)
            .padding()
            .background(LinearGradient(gradient: Gradient(colors: [Color.red, Color("LightGreen"), Color("DarkGreen")]), startPoint: /*@START_MENU_TOKEN@*/.leading/*@END_MENU_TOKEN@*/, endPoint: /*@START_MENU_TOKEN@*/.trailing/*@END_MENU_TOKEN@*/))
            .font(.largeTitle)
            .foregroundColor(.white)
            .cornerRadius(40)
            .shadow(radius: 5.0)
            .padding(.horizontal)
        }
    }
}

struct ButtonFive: View {
    var body: some View {
        Button( role: .destructive){
            print("点击了按钮")
        }label: {
            Label(
                title: { Text("编           辑")
                        .fontWeight(.semibold)
                        .font(.title) },
                icon: { Image(systemName: "square.and.pencil")
                    .font(.title) }
            )
        }
        .buttonStyle(GradientBackgroundStyle())
    }
}

#Preview {
    SwiftUIButtons()
}
